<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>求和</title>
</head>
<body>
<script>
    function foo(num) {
        if (num%2==1){
            num = num -1;
        }

        if (num == 0) {
            return 0;

        } else {
                console.log(num);
                return num + foo(num - 2)
        }
    }
    console.log(foo(100))
</script>
</body>
</html>